package com.omega_r.libs.omegarecyclerview.viewpager.default_transformers;

import ohos.agp.components.Component;

/**
 * 由于有些API在鸿蒙中没找到对应的 故此动画空实现
 * setRotationY
 *
 * @since 2021-04-12
 */
public class FlipTransformer extends ABaseTransformer {

    @Override
    public boolean isPagingEnabled() {
        return true;
    }

    @Override
    protected void onTransform(Component component, float position) {
        float rotation = 180f * position;
        component.setRotation(rotation);
        component.setTranslationX(-component.getWidth() * position);
        component.setAlpha(rotation > 90f || rotation < -90f ? 0 : 1);
        component.setPivotX(component.getWidth() * 0.5f);
        component.setPivotY(component.getHeight() * 0.5f);
    }

    @Override
    protected void onPostTransform(Component component, float position) {
    }
}
